git push时候总提示输入账号密码,如何避免?

问题:git push 的时候总提示输入账号密码,如何避免?

~/下, touch创建文件.git-credentials, 用vim编辑此文件,输入内容格式:

1
2
3
$ touch .git-credentials
$ vim .git-credentials
https://{username}:{password}@github.com

1、 在终端下执行

1
$ git config --global credential.helper store

2、 可以看到~/.gitconfig文件,会多了一项:

1
2
[credential]
helper = store

这样就可以免密码 push 了